//
//  YBManageWalletViewController+LayoutConstraints.m
//  Nectar
//
//  Created by famer on 2023/11/8.
//  Copyright © 2023 asance. All rights reserved.
//

#import "YBManageWalletViewController+LayoutConstraints.h"
#import "YBNavigationBar.h"

@implementation YBManageWalletViewController (LayoutConstraints)

- (void)setLayoutConstraints{
    CGFloat width = self.view.size.width;
    CGFloat height = self.view.size.height;
    CGFloat leftMargin = 12;
    CGFloat titleRowHeight = 55;
    CGFloat detailRowHeight = 44;

    self.navigationBar.frame = CGRectMake(0,  [UIView statusBarHeight], width, 64);
    self.contentView.frame = CGRectMake(0, self.navigationBar.bottom, width, height-self.navigationBar.bottom);
    
    self.userNameContentView.frame = CGRectMake(0, 1, self.contentView.width, 0);
    
    CGSize userNameLabelSize = [self.userNameLabel textBoundingSizeWithMaxSize:CGSizeMake(self.userNameContentView.width, 500)];
    
    CGSize userNameValueLabelSize = [self.userNameValueLabel textBoundingSizeWithMaxSize:CGSizeMake(self.userNameContentView.width-leftMargin, 500)];

    self.userNameLabel.frame = CGRectMake(leftMargin, 16, self.userNameContentView.width-leftMargin, userNameLabelSize.height);
    self.userNameValueLabel.frame = CGRectMake(leftMargin, self.userNameLabel.bottom+6, self.userNameContentView.width, userNameValueLabelSize.height);
    
    self.userNameContentView.height = self.userNameValueLabel.bottom+16;

    self.walletContentView.frame = CGRectMake(0, self.userNameContentView.bottom+12, self.contentView.width, 0);
    self.walletAddressLabel.frame = CGRectMake(leftMargin, 16, self.walletContentView.width-12, userNameLabelSize.height);
    
    CGSize walletAddressValueLabelSize = [self.walletAddressValueLabel textBoundingSizeWithMaxSize:CGSizeMake(self.walletContentView.width-12, 500)];

    self.walletAddressValueLabel.frame = CGRectMake(leftMargin, self.walletAddressLabel.bottom+6, self.walletContentView.width-12, walletAddressValueLabelSize.height);
    
    self.walletLineView.frame = CGRectMake(0, self.walletAddressValueLabel.bottom+16, self.walletContentView.width, 1);
    
    self.walletNameLabel.frame = CGRectMake(leftMargin, self.walletLineView.bottom+16, self.walletContentView.width-leftMargin, userNameLabelSize.height);
    self.walletNameEditImageView.frame = CGRectMake(self.walletContentView.width-20-leftMargin, self.walletNameLabel.top, 20, userNameLabelSize.height);
    self.walletNameEditImageView.contentMode = UIViewContentModeScaleAspectFit;
        
    CGSize walletNameValueLabelSize = [self.walletNameValueLabel textBoundingSizeWithMaxSize:CGSizeMake(self.walletNameEditImageView.left-leftMargin*2, 500)];
    self.walletNameValueLabel.frame = CGRectMake(self.walletNameEditImageView.left-walletNameValueLabelSize.width-leftMargin,
                                                 self.walletNameLabel.top,
                                                 walletNameValueLabelSize.width,
                                                 userNameLabelSize.height);
    
    self.walletNameEditButton.frame = CGRectMake(0, self.walletNameLabel.top, self.walletContentView.width, self.walletNameLabel.height);

    self.walletContentView.height = self.walletNameLabel.bottom+16;

}

@end
